<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<?php include ("inc/check_authen/check_authen.php");?>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>::Patani Forum:: Gallery Management</title>



<script type="text/javascript" src="../js/jquery.min.js"></script>
<script type="text/javascript" src="../js/jquery_pagination.js"></script>
<script type="text/javascript" src="../object/coreObject/fix/FixArticleTypeObj.js"></script>
<script type="text/javascript" src="jquery/ckeditor/ckeditor.js"></script>

<link rel="stylesheet" type="text/css" href="css/admincss.css" />
<link rel="stylesheet" type="text/css" href="css/add_articlecss.css" />
<link rel="stylesheet" type="text/css" href="css/admingallery.css" />
<link  rel="stylesheet" type="text/css" href="css/webmaster.css"/>

<?php 

if(isset($_GET['album_id'],$_GET['album_name']))
{
	include('../dbconfig.php');
	$src = "../images/uploads/".$_GET['album_id']."_".iconv("UTF-8","windows-874",$_GET['album_name']);
	if(is_dir($src)){
		$src = (substr($src, -1) != "/")? $src."/":$src; 
		$opendir = opendir($src); 
		while($file = readdir($opendir)) 
		{ 
			if(!in_array($file, array(".", ".."))) 
			{ 
				if(!is_dir($src.$file)) 
				{
					@unlink($src.$file); 
				} else 
				{ 
					remove_dir($src.$file); 
				} 
			} 
		} 
		closedir($opendir); 
		@rmdir($src);
		$sql = "DELETE FROM album WHERE album_id=".$_GET['album_id'];
		$sql = mysql_query($sql);
	}
}
?>
<script type="text/javascript">
	//เมื่อคลิกที่ เพิ่มข่าว จะดึงหน้า เพิ่มข่าวมาแทนที่ หน้าเดิม
	function gallery_imgAdd_Onclick()
	{
		try
		{
			var url = "dialog/dia_album_upload.php";
			var args = "";
			var str = "scroll:no;status:no; help:no; dialogWidth:700px; dialogHeight:300px";
			var arr = showModalDialog( url , args , str );
			if(arr != null)
				window.location="gallery.php";
		}
		catch(e)
		{
			;
		}
	}
	//เมื่อคลิ๊กที่ แก้ไขอัลบั้ม จะดึงหน้า แก้ไขอัลบั้มขึ้นมาเป็น dialog
	function gallery_albumEdit_Onclick(albumId,albumName,albumDescription,albumPhotographer)
	{
		try
		{
			var url = "dialog/diaedit_album_upload.php?album_id="+albumId+"&album_name="+albumName+"&albumdescription="+albumDescription+"&photographer="+albumPhotographer;
			var args = "";
			var str = "scroll:no;status:no; help:no; dialogWidth:700px; dialogHeight:300px";
			var arr = showModalDialog( url , args , str );
			if(arr != null)
				window.location="gallery.php";
		}
		catch(e)
		{
			;
		}
	}
	//ลบรูปภาพที่เลือก
	function delete_album(albumId,albumname)
	{
		if(confirm("ยืนยันการลบอัลบั้ม "+albumname+" ใช่หรือไม่?"))
		{
	        window.location="gallery.php?album_id="+albumId+"&album_name="+albumname;
		}
			
	}
		
	function gallery_imgManage_Onclick(albumFolder)
	{
		window.location = "gallery_detail.php?album="+albumFolder;
	}

	//ajax ที่ใช้ในการ เปลี่ยนหน้า page บางส่วน ในการ add
	function requestFile(url,isShow) {
		if (window.XMLHttpRequest) {
			xmlhttp=new XMLHttpRequest();
		}		
		else {
			xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
		}
		xmlhttp.open("POST",url,false);
		xmlhttp.send(null);
		
		document.getElementById('gallry_content').innerHTML=xmlhttp.responseText;
	}

</script>
</head>
<body id="body" class="oneColElsCtrHdr">
<!-- Start #container -->
<div id="container">
<!-- Start header -->
	<?php include("inc/layout/header/admin_header.php");?>
<!-- End header -->
<!-- Start Navigator -->
	<?php include("inc/layout/navigator/admin_navigator.php");?>
<!-- End Navigator -->
<!-- Start Content -->
	<div id="gallry_content">
		<?php include("inc/content/gallery/admin_gallery_content.php");?>
	</div>
<!-- End Content -->
<!-- Start Footer -->
	<?php include("inc/layout/footer/admin_footer.php");?>
<!-- End Footer -->	
</div>
</body>
</html>
